﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.ObjectConverter;
using JXT.PrimaryKey.Batman.Domain.UserSystem.Models;
using DTO = JXT.PrimaryKey.Batman.WcfService.Models.UserSystem;

namespace JXT.PrimaryKey.Batman.WcfService.Services.Converters.UserSystem
{
    public class RoleConverter : AutoConvertableBase<Role, DTO.Role, RoleConverter>, IConvertable<Role, DTO.Role>
    {
        protected override void BuildExpressionConverter(IObjectConverter<Role, DTO.Role> converter)
        {
            base.BuildExpressionConverter(converter);
            converter.AddEnumerable(e => e.Authorities, e => e.Authorities, AuthorityConverter.Instanse.Converter);
        }

        protected override void BuildExpressionBackConverter(IObjectConverter<DTO.Role, Role> backConverter)
        {
            base.BuildExpressionBackConverter(backConverter);
            backConverter.AddEnumerable(e => e.Authorities, e => e.Authorities, AuthorityConverter.Instanse.BackConverter);
        }
    }
}
